package com.ck.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ck.common.entity.SysLogininfor;
import com.ck.system.mapper.SysLogininforMapper;
import com.ck.system.service.SysLogininforService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author changk
 * @date 2024/12/10 15:43
 */
@Service
public class SysLogininforServiceImpl implements SysLogininforService {
    @Autowired
    private SysLogininforMapper logininforMapper;

    /**
     * 新增系统登录日志
     *
     * @param logininfor 访问日志对象
     */
    @Override
    public void insertLogininfor(SysLogininfor logininfor)
    {
        logininforMapper.insertLogininfor(logininfor);
    }

    /**
     * 查询系统登录日志集合
     *
     * @param logininfor 访问日志对象
     * @return 登录记录集合
     */
    @Override
    public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor)
    {
        return logininforMapper.selectLogininforList(logininfor);
    }

    /**
     * 批量删除系统登录日志
     *
     * @param infoIds 需要删除的登录日志ID
     * @return 结果
     */
    @Override
    public int deleteLogininforByIds(Long[] infoIds)
    {
        return logininforMapper.deleteLogininforByIds(infoIds);
    }

    /**
     * 清空系统登录日志
     */
    @Override
    public void cleanLogininfor()
    {
        logininforMapper.cleanLogininfor();
    }


    /**
     * 分页查询登录日志(基于MP插件)
     *
     * @param pageNum
     * @param pageSize
     */
    @Override
    public IPage<SysLogininfor> getLoginInfoForMP(Integer pageNum, Integer pageSize) {
        Page<SysLogininfor> page = new Page<>(pageNum, pageSize);
        return logininforMapper.selectLoginInfoForMP(page);
    }

    /**
     * 分页查询登录日志(基于pageHelper插件)
     *
     * @return
     */
    @Override
    public List<SysLogininfor> getLoginInfoForPH() {
        return logininforMapper.selectLoginInfoForPH();
    }

}
